home *** CD-ROM | disk | FTP | other *** search
Text File | 1995-06-16 | 4.6 KB | 154 lines | [TEXT/MMCC] |
- // ShowHideCorners.c
- //
- // David Hayward
- // Developer Technical Support
- // AppleLink: DEVSUPPORT
- //
- // Copyrite 1993, Apple Computer,Inc
- //
- // This file contains routines to sho/hide the
- // rounded corners in each monitor.
- //
- // 12/10/93 david first cut
-
-
- #include <Windows.h>
- #include <QuickDraw.h>
- #include <LowMem.h>
-
- #include "ShowHideUtils.h"
- #include "ShowHideCorners.h"
-
-
- /**\
- |**| ==============================================================================
- |**| GLOBALS
- |**| ==============================================================================
- \**/
- short gCornersState = SHOW;
- RgnHandle crnrRgn;
-
-
- /**\
- |**| ==============================================================================
- |**| PRIVATE FUNCTION PROTOTYPES
- |**| ==============================================================================
- \**/
- void GetCornerRgn (RgnHandle crnrRgn);
-
-
- /**\
- |**| ==============================================================================
- |**| PUBLIC FUNCTIONS
- |**| ==============================================================================
- \**/
-
-
- /*------------------------------------------------------------------------------*\
- SetCornersState
- *------------------------------------------------------------------------------*
- changes the corners state to either SHOW or HIDE
- \*------------------------------------------------------------------------------*/
- void SetCornersState (char vis)
- {
- static short first = true;
- RgnHandle GrayRgn = LMGetGrayRgn();
-
- if (first) /* if its the 1st time called */
- { /* this oviously doen't do much but */
- first = false; /* I include it to emphasize the */
- } /* parallel with SetCornersState() */
-
- if (vis == gCornersState) /* return if nothing would change */
- return;
-
- if (!vis) /* if HIDE */
- {
- crnrRgn = NewRgn();
- GetCornerRgn(crnrRgn); /* make a region for the corners */
- UnionRgn(GrayRgn,crnrRgn,GrayRgn); /* tell the desktop it covers the corners */
-
- SH_ForceUpdate(crnrRgn);
- }
-
- else /* if SHOW */
- {
- GrafPtr savePort;
-
- GetPort(&savePort);
-
- SetPort(LMGetWMgrPort());
- SetClip(crnrRgn);
- FillRgn(crnrRgn,&(qd.black)); /* redraw the corners */
-
- SetPort(savePort);
-
- DiffRgn(GrayRgn, crnrRgn, GrayRgn); /* remove the corners from the desktop rgn */
- DisposeRgn(crnrRgn); /* dispose to the corners region */
- }
- gCornersState = !gCornersState; /* toggle the state */
- }
-
-
- /*------------------------------------------------------------------------------*\
- GetCornersState
- *------------------------------------------------------------------------------*
- an accessor to allow others to read private gCornersState global
- \*------------------------------------------------------------------------------*/
- char GetCornersState (void)
- {
- return gCornersState;
- }
-
-
- /**\
- |**| ==============================================================================
- |**| PRIVATE FUNCTIONS
- |**| ==============================================================================
- \**/
-
-
- /*------------------------------------------------------------------------------*\
- GetCornerRgn
- *------------------------------------------------------------------------------*
- uses globals to calculate the region for the rounred corners
- the RgnHandle crnrRgn must be allocated with NewRgn() before calling
- \*------------------------------------------------------------------------------*/
- void GetCornerRgn (RgnHandle crnrRgn)
- {
- Rect mBarRect;
- RgnHandle tmpRgn;
- Rect gDeviceRect;
- GDHandle gDevice;
- RgnHandle GrayRgn = LMGetGrayRgn();
-
- tmpRgn = NewRgn();
-
- /* Get the handle to the first device in the list. */
- gDevice = GetDeviceList();
-
- /* Loop through all the devices in the list in order */
- /* to create a region for all the screens' boundaries*/
- while (gDevice != nil)
- {
- gDeviceRect = (**gDevice).gdRect; /* the bounding rect of this device */
- RectRgn(tmpRgn, &gDeviceRect); /* convert rect to a region */
- UnionRgn(crnrRgn,tmpRgn,crnrRgn); /* add device's rect to region */
- gDevice = GetNextDevice( gDevice ); /* get next device and repeat... */
- }
-
- /* subtract the GrayRgn from the above. This leaves a region */
- /* which contains the menuBar and any rounded corners. */
- DiffRgn(crnrRgn,GrayRgn,crnrRgn); /* remove GrayRgn from crnrRgn */
-
-
- /* now subtract the MenuBar region (if any). */
- /* This leaves just the rounded corners. */
- mBarRect = qd.screenBits.bounds; /* create a rect for the mbar */
- mBarRect.bottom = mBarRect.top + GetMBarHeight();
- RectRgn(tmpRgn, &mBarRect); /* make a region for the mbar */
- DiffRgn(crnrRgn,tmpRgn,crnrRgn); /* remove mbar from crnrRgn */
-
- DisposeRgn(tmpRgn);
- }
-